package com.free.system.service.impl;

import com.free.common.core.text.Convert;
import com.free.common.utils.DateUtils;
import com.free.system.domain.FreeTicketClickTask;
import com.free.system.mapper.FreeTicketClickTaskMapper;
import com.free.system.service.IFreeTicketClickTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 票券定时触发Service业务层处理
 *
 * @author Sophia
 * @date 2025-02-27
 */
@Slf4j
@Service
public class FreeTicketClickTaskServiceImpl implements IFreeTicketClickTaskService {

    @Autowired
    private FreeTicketClickTaskMapper freeTicketClickTaskMapper;

    /**
     * 查询票券定时触发
     *
     * @param id 票券定时触发主键
     * @return 票券定时触发
     */
    @Override
    public FreeTicketClickTask selectFreeTicketClickTaskById(Long id) {
        return freeTicketClickTaskMapper.selectFreeTicketClickTaskById(id);
    }

    /**
     * 查询票券定时触发列表
     *
     * @param freeTicketClickTask 票券定时触发
     * @return 票券定时触发
     */
    @Override
    public List<FreeTicketClickTask> selectFreeTicketClickTaskList(FreeTicketClickTask freeTicketClickTask) {
        return freeTicketClickTaskMapper.selectFreeTicketClickTaskList(freeTicketClickTask);
    }

    /**
     * 新增票券定时触发
     *
     * @param freeTicketClickTask 票券定时触发
     * @return 结果
     */
    @Override
    public int insertFreeTicketClickTask(FreeTicketClickTask freeTicketClickTask) {
        freeTicketClickTask.setCreateTime(DateUtils.getNowDate());
        return freeTicketClickTaskMapper.insertFreeTicketClickTask(freeTicketClickTask);
    }

    /**
     * 修改票券定时触发
     *
     * @param freeTicketClickTask 票券定时触发
     * @return 结果
     */
    @Override
    public int updateFreeTicketClickTask(FreeTicketClickTask freeTicketClickTask) {
        freeTicketClickTask.setUpdateTime(DateUtils.getNowDate());
        return freeTicketClickTaskMapper.updateFreeTicketClickTask(freeTicketClickTask);
    }

    /**
     * 批量删除票券定时触发
     *
     * @param ids 需要删除的票券定时触发主键
     * @return 结果
     */
    @Override
    public int deleteFreeTicketClickTaskByIds(String ids) {
        return freeTicketClickTaskMapper.deleteFreeTicketClickTaskByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除票券定时触发信息
     *
     * @param id 票券定时触发主键
     * @return 结果
     */
    @Override
    public int deleteFreeTicketClickTaskById(Long id) {
        return freeTicketClickTaskMapper.deleteFreeTicketClickTaskById(id);
    }
}
